//
//  AccountUrl.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/21.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "AccountUrl.h"

static AccountUrl *accountUrl = nil;

@implementation AccountUrl

+ (instancetype)shared
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        accountUrl = [[AccountUrl alloc] init];
    });
    return accountUrl;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
    if (!accountUrl)
    {
        accountUrl = [super allocWithZone:zone];
    }
    return accountUrl;
}

- (id)copy
{
    return self;
}

- (id)mutableCopy
{
    return self;
}

#pragma mark - 发送验证码
- (void)verificationGetRequest:(NSDictionary *)dict
{
    [KQNetWork postWithURLString:[NSString stringWithFormat:@"%@/api/index/registercode",MAIN_URL] parameters:dict success:^(NSDictionary *dic) {
        
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark - 密码登陆
- (void)PasswordToLogin:(NSDictionary *)dict
{
    [KQNetWork postWithURLString:[NSString stringWithFormat:@"%@/api/index/login",MAIN_URL] parameters:dict success:^(NSDictionary *dic) {
        
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark - 忘记密码
- (void)forgotpassword:(NSDictionary *)dict
{
    [KQNetWork postWithURLString:[NSString stringWithFormat:@"%@",MAIN_URL] parameters:dict success:^(NSDictionary *dic) {
        
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark - 获取当前时间
- (NSInteger)getNowExpired_time
{
    NSString *urlString = @"http://www.baidu.com";
    urlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString: urlString]];
    [request setCachePolicy:NSURLRequestReloadIgnoringCacheData];
    [request setTimeoutInterval: 2];
    [request setHTTPShouldHandleCookies:FALSE];
    [request setHTTPMethod:@"GET"];
    NSHTTPURLResponse *response;
    [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
    NSString *date = [[response allHeaderFields] objectForKey:@"Date"];
    
    date = [date substringFromIndex:5];
    date = [date substringToIndex:[date length]-4];
    NSDateFormatter *dMatter = [[NSDateFormatter alloc] init];
    dMatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
    [dMatter setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
    NSDate *netDate = [[dMatter dateFromString:date] dateByAddingTimeInterval:60*60*8];
    return [netDate timeIntervalSince1970];
}

@end
